//
//  M_MineJiFenViewController.m
//  Model
//
//  Created by apple on 2018/9/1.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "M_MineJiFenViewController.h"
#import "M_MineJiFenTableViewCell.h"
@interface M_MineJiFenViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) UIButton *jiFenBtn;//积分
@property (nonatomic, strong) UIButton *duiHuanBtn;//兑换

@end

@implementation M_MineJiFenViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
 
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"积分";
    [self creationHeadView];
    [self creationTableView];
    [self regeditCell];
    
    // Do any additional setup after loading the view.
}
- (void)creationHeadView{
    
    UIView *headRootView = [[UIView alloc] init];
    [self.view addSubview:headRootView];
    [headRootView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.top.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(74);
        
    }];
    headRootView.backgroundColor =getColor(@"f7f7f7");
    
    UIView *headView = [[UIView alloc] init];
    [headRootView addSubview:headView];
    headView.backgroundColor = [UIColor whiteColor];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(12);
        make.top.equalTo(self.view).with.offset(12);
        make.right.equalTo(self.view).with.offset(-12);
        make.height.offset(50);

    }];
    headView.layer.cornerRadius = 10;
    headView.layer.masksToBounds = YES;
    headView.layer.borderWidth = 1.0f;
    headView.layer.borderColor = getColor(@"ff40c6").CGColor;
    self.view.backgroundColor = [UIColor whiteColor];
 
    self.jiFenBtn = [[UIButton alloc] init];
    [headView addSubview:self.jiFenBtn];
    [self.jiFenBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headView);
        make.left.equalTo(headView);
        make.bottom.equalTo(headView);
        make.width.offset(DEF_SCREEN_WIDTH/2-12);
        
    }];
    [self.jiFenBtn setBackgroundImage:[UIImage imageNamed:@"b_suibian"] forState:UIControlStateNormal];
//    self.jiFenBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.jiFenBtn setTitle:@"积分总数\n9999" forState:UIControlStateNormal];

    [self.jiFenBtn.titleLabel setNumberOfLines:0];
    [self.jiFenBtn.titleLabel setTextAlignment:NSTextAlignmentCenter];

    self.duiHuanBtn = [[UIButton alloc] init];
    [headView addSubview:self.duiHuanBtn];
    [self.duiHuanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headView);
        make.right.equalTo(headView);
        make.bottom.equalTo(headView);
        make.width.offset(DEF_SCREEN_WIDTH/2-12);
        
    }];
    [self.duiHuanBtn setBackgroundImage:[UIImage imageNamed:@"b_suibian"] forState:UIControlStateNormal];
    //    self.jiFenBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.duiHuanBtn setTitle:@"兑换数量\n9999" forState:UIControlStateNormal];
    
    [self.duiHuanBtn.titleLabel setNumberOfLines:0];
    [self.duiHuanBtn.titleLabel setTextAlignment:NSTextAlignmentCenter];

}
- (void)creationTableView{
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 74, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64-74);
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    
}

- (void)regeditCell{
    
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"M_MineJiFenTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_MineJiFenTableViewCell"];
    
}
#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 30;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 50;
    
}
#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    M_MineJiFenTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_MineJiFenTableViewCell" forIndexPath:indexPath];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    
    return cell;
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
